<%@ page language="java" contentType="text/html;"
    pageEncoding="UTF-8"
    import="java.util.*"%>
    
<link href="css/main.css" rel="stylesheet" type="text/css">

<script src="http://static.ak.facebook.com/js/api_lib/v0.3/FeatureLoader.js" type="text/javascript"></script>
<script type="text/javascript">
	FB_RequireFeatures(["CanvasUtil"], function(){
	FB.XdComm.Server.init('<%= request.getAttribute("FB_SERVER_URL") %>xd_receiver.htm');
	FB.CanvasClient.startTimerToSizeToContent();
});
</script>
 

  <!-- Begin Wrapper -->
   <div id="wrapper">
   
         <!-- Begin Header -->
         <div id="header">
		 
		        
			   
		 </div>
		 <!-- End Header -->
		 
		 <!-- Begin Naviagtion -->
         <div id="navigation">
		 	  <ul class="nav">
				<li><a href="<%= request.getAttribute("FB_APP_URL") %>" target="_top">Home</a></li>
				<li><a href="<%= request.getAttribute("FB_APP_URL") %>BaffesServlet" target="_top">Baffes</a></li>
				<li><a href="<%= request.getAttribute("FB_APP_URL") %>GrapheServlet" target="_top">Graphe des amis</a></li>
				<li><a class="current" href="<%= request.getAttribute("FB_APP_URL") %>HistoriqueServlet" target="_top">Historique</a></li>
				<li><a href="<%= request.getAttribute("FB_APP_URL") %>invitation.jsp?api_key=<%= request.getAttribute("FB_API_KEY") %>&app_name=<%= request.getAttribute("FB_APP_NAME") %>&v=1.0&fb_force_mode=fbml" target="_top">Inviter des Amis</a></li>
			</ul>    
		 </div>
		 <!-- End Naviagtion -->
		 
		 <!-- Begin Content -->
		 <div id="content">
		     <h2> Baffes Timeline </h2>  
	    	 <%
	
	    	ArrayList <HashMap<String,String>> array = (ArrayList <HashMap<String,String>>) request.getAttribute("array");
	    	HashMap<String,HashMap<String,String>> infos = (HashMap<String,HashMap<String,String>>) request.getAttribute("infos");
			if(array != null){
				for(int i=0;i < array.size();i++){
					HashMap<String,String> baffe = array.get(i);
					String uid1 = baffe.get("id_envoyeur");
					String uid2 = baffe.get("id_receveur");
					
					String time = baffe.get("time");
					
					String username1 = infos.get(uid1).get("name");
					String username2 = infos.get(uid2).get("name");
					
					String pic_square1 = infos.get(uid1).get("pic_square");
					String pic_square2 = infos.get(uid2).get("pic_square");
					
					if (baffe.get("sens").equals("baffeur")){
						%>
						<p class='timeline'>
						<img src="<%=pic_square1%>" />
						<img src="<%=pic_square2%>" />
						Vous avez baffé <a target='_top' href="http://www.facebook.com/profile.php?id=<%=uid2%>"><%=username2%></a> le <%=time%> </p>
						<%
					}else{
						%>
						<p class='timeline'>
						<img src="<%=pic_square2%>" />
						<img src="<%=pic_square1%>" />
						<a target='_top' href="http://www.facebook.com/profile.php?id=<%=uid2%>"><%=username2%></a> vous a baffé le <%=time%> </p>
						<%
					}
				}
			}
	
			Date now = new Date();
		    
			%>
		 
		 
		 </div>
		 <!-- End Content -->
		 
		 <!-- Begin Footer -->
		 <div id="footer">
		       
			    <jsp:include page="footer.jsp" />
			    
	     </div>
		 <!-- End Footer -->
		 
   </div>
   <!-- End Wrapper -->
 